package demo.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import demo.common.utils.BeanHelper;
import demo.user.dto.MenuDTO;
import demo.user.mapper.MenuMapper;
import demo.user.pojo.Menu;
import demo.user.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LonelySnow
 * @since 2020-06-15
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public MenuDTO getUserMenu(Long uid, String uri) {
        List<Menu> menuList = menuMapper.getUserMenu(uid, uri);
        Menu menu = menuList.get(0);
        MenuDTO menuDTO = BeanHelper.copyProperties(menu, MenuDTO.class);
        return menuDTO;
    }
}
